package com.kpmg.questionnaire.repository;

import com.kpmg.questionnaire.model.QuestionEntity;
import com.kpmg.questionnaire.model.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by xionghao on 2016/11/9.
 */
@Repository // 添加注解
public interface QuestionRepository extends JpaRepository<QuestionEntity, Integer> {
    @Modifying // 说明该方法是修改操作
    @Transactional // 说明该方法是事务性操作
    // 定义查询
    // @Param注解用于提取参数
    @Query("update QuestionEntity us set us.content=:qContent, us.type=:qType, us.impact=:qImpact, us.choose1=:qChosse1," +
            "us.choose2=:qChosse2,us.choose3=:qChosse3,us.choose4=:qChosse4,us.choose5=:qChosse5," +
            "us.survey=:qSurvey, us.score=:qScore, us.note=:qNote where us.id=:qId")
    public void updateItem(@Param("qContent") String content,
                           @Param("qType") String type,
                           @Param("qImpact") String impact,
                           @Param("qChosse1") String choose1,
                           @Param("qChosse2") String choose2,
                           @Param("qChosse3") String choose3,
                           @Param("qChosse4") String choose4,
                           @Param("qChosse5") String choose5,
                           @Param("qSurvey") String survey,
                           @Param("qScore") Integer score,
                           @Param("qNote") String note,
                           @Param("qId") Integer id);
}
